package com.baoming.container;

import org.apache.commons.lang.StringUtils;
 

public class ServiceContainer {
	private static ServiceProviderCord serviceProvider = null ; 
	static{
		serviceProvider = new ServiceProviderCord() ; 
		serviceProvider.load("applicationContext.xml") ;  
	}
	
	public static Object getService(String serviceName){
		
		if(StringUtils.isBlank(serviceName)){
			throw new RuntimeException("找不到服务  ... ") ; 
		}
		Object object = null ; 
		 
		if(serviceProvider.applicationContext.containsBean(serviceName)){
			object = serviceProvider.applicationContext.getBean(serviceName) ; 
		}
		 
		if(object==null){
			throw new RuntimeException("系统服务名 "+serviceName+" 异常");
		}
		
		return object ; 
	}
}
